//
//  ViewController.m
//  网络请求(GET&POST)
//
//  Created by My Mac on 2017/4/13.
//  Copyright © 2017年 My Mac. All rights reserved.
//

#import "ViewController.h"
#import "HttpPostRequest.h"
#import "HttpGetRequest.h"
#import "HttpUtil.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString *urlString = @"http://dev1.cn:8888";
    NSMutableDictionary *parameters = [NSMutableDictionary new];
    parameters[@"action"] = @"get";
    parameters[@"object"] = @"status";
    
    //HttpUtil通用类调试(get post 都可以),这里是post 传入网址，请求体：如上所示parameters字典
    [HttpUtil requestWithURLString:urlString httpMethod:@"post" httpBody:parameters handler:^(id  _Nullable value) {
        NSDictionary *dict = value;
        NSLog(@"%@",dict);
    }];
    
    //单独的post类网络连接
    [HttpPostRequest postRequestWithURLString:urlString HttpBody:parameters Handler:^(id _Nullable value) {
        NSDictionary *dict = value;
        NSLog(@"%@",dict);
    }];
    
    //单独的get类网络连接
    [HttpGetRequest getRequestWithURLString:@"http://a.xl18z.cn/api/login?name=root&password=125" Handler:^(id  _Nullable value) {
        NSDictionary *dict = value;
        NSLog(@"%@",dict);
    }];
    
    //HttpUtil通用类调试(get post 都可以),这里是get ，传入网址，get请求不需要请求体：所以 填nil
    [HttpUtil requestWithURLString:@"http://a.xl18z.cn/api/login?name=root&password=125" httpMethod:@"get" httpBody:nil handler:^(id  _Nullable value) {
        NSDictionary *dict = value;
        NSLog(@"%@",dict);
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
